/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package bancoDados;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Felipe Tadeu
 */
public class DAO {
    
    protected Connection conn;
    
    String url = "jdbc:mysql://localhost:3306/busca_precos";
    String usuario = "root";
    String senha = "root";
    
    public void conectar(){
        try {
            Class.forName("com.mysql.jdbc.Driver").newInstance();
            this.conn = DriverManager.getConnection(url, usuario, senha);
           
        } catch (Exception ex) {
            Logger.getLogger(DAO.class.getName()).log(Level.SEVERE, null, ex);
        } 
    }
    
    public void desconectar() {
        try {
            if (this.conn != null) {
                this.conn.close();
            }
        } catch (Exception ex) {
            Logger.getLogger(DAO.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}
